<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" name="" id="" class="name" placeholder="姓名">
    <input type="text" name="" id="" class="age" placeholder="年龄">
    <button>添加</button>
    <script>
        let inputName=document.querySelector(".name")
        let inputAge=document.querySelector(".age")
        let button=document.querySelector("button")
        let studentList=[]
        // let student=[]
        class Student{
            constructor(name,age){
                this.name=name
                this.age=age
            }
        }
        button.onclick=function(){
            // student.name=inputName.value
            // student.age=inputAge.value
            // console.log(student)
            let student =new Student(inputName.value,inputAge.value)
            studentList.push(student)
            console.log(studentList)
        }
    </script>
</body>
</html>